<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//Dtd bgcolor="ffffff" HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd bgcolor="ffffff"">
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%String cpath=request.getContextPath(); %>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>쿠폰 메인페이지</title>
<link href="<%=cpath%>/resources/css/coupon_css.css" rel="stylesheet" type="text/css">
<%@include file="/WEB-INF/Top.jsp" %>


</head>
<body>
<p>&nbsp;</p>
<table width="346" height="20" border="0">
  <tr>
    <td width="150"><div align="center">
      <input type="button" name="discount"  onclick="location.href='discount'" value="할인율">
    </div></td>
    <td width="150"><div align="center">
      <input type="button" name="today"  onclick="location.href='today'" value="오늘까지">
    </div></td>
    <td width="150"><div align="center">
      <input  type="button" name="readcnt" onClick="location.href='readcnt'" value="조회수">
    </div></td>
  </tr>
</table>

<table width="900" border="0" cellspacing="10">
   <tr>
    <c:if test="${listDTO.listcount == 0}">
   	  등록된 쿠폰이 없습니다
    </c:if>
   
    <c:if test="${listDTO.listcount != 0}">
     <c:forEach items="${listDTO.list }" var="list" varStatus="status">
     
     <td width="600">
     
     <table width="156" border="0" cellpadding="10">
    
       <tr>
         <td width="146" height="104" align="center" valign="top">
	         <a href="<%=cpath %>/coupon/view?coupon_num=${list.coupon_num}" target="_blank">
             <img src="/food/resources/coupon/${list.coupon_image}" width="100" height="100" border="0" ></a></td>
       </tr>
       <tr>
         <td width="146" height="184" align="center" valign="top">
           	 <a href="<%=cpath %>/coupon/view?coupon_num=${list.coupon_num}" target="_blank">${list.coupon_name}</a><br>
          <br>
             ${list.coupon_details}<br><br>
             ${list.coupon_discount}%<br><br>
             ${list.coupon_enddate}까지<br><br>
             	조회수:${list.coupon_readcnt}
         </td>
       </tr>
      </table>
     </td>
     
     <c:if test="${status.count%4==0 }">
    </tr> 
    
    <tr>
     </c:if>
     
      
   
         
 </c:forEach>
  </c:if>
 </tr>
 
  <tr>
  <td>
  <input type="button" value="쿠폰등록" onClick="location.href='<%=cpath%>/coupon/insert'">
  </td>
  </tr>
  <tr>
  <td colspan="11" bgcolor="#ffffff">
  <!--페이징처리 -->
  
 	<c:if test="${listDTO.prevPage > 0}">
	 	<c:if test="${list == 'list'}">
			<a href="<%=cpath%>/coupon/home/list?curPage=${listDTO.prevPage }">[이전]</a>
		</c:if>
		<c:if test="${discount == 'discount'}">
			<a href="<%=cpath%>/coupon/home/discount?curPage=${listDTO.prevPage }">[이전]</a>
		</c:if>
		<c:if test="${today == 'today'}">
			<a href="<%=cpath%>/coupon/home/today?curPage=${listDTO.prevPage }">[이전]</a>
		</c:if>
		<c:if test="${readcnt == 'readcnt'}">
			<a href="<%=cpath%>/coupon/home/readcnt?curPage=${listDTO.prevPage }">[이전]</a>
		</c:if>
	</c:if>
	
	
	<!-- 조건절(현재페이지에서는 링크 없고, 다른페이지만 링크보이게) -->
	<c:forEach var="cnt" begin="${listDTO.firstPage }" end="${listDTO.lastPage }" step="1">
		<c:choose>
			<c:when test="${cnt == listDTO.curPage }">
				[${cnt }]
			</c:when>
			<c:when test="${list == 'list'}">
				<a href="<%=cpath%>/coupon/home/list?curPage=${cnt }">[${cnt }]</a>
			</c:when>
			<c:when test="${discount == 'discount'}">
				<a href="<%=cpath%>/coupon/home/discount?curPage=${cnt }">[${cnt }]</a>
			</c:when>
			<c:when test="${readcnt == 'readcnt'}">
				<a href="<%=cpath%>/coupon/home/readcnt?curPage=${cnt }">[${cnt }]</a>
			</c:when>
			<c:otherwise>
				<a href="<%=cpath%>/coupon/home/today?curPage=${cnt }">[${cnt }]</a>
			</c:otherwise>
		</c:choose>
	</c:forEach>
	<!-- 다음 링크[다음] -->
	<c:if test="${listDTO.nextPage >0 }">
		<c:if test="${list == 'list'}">
			<a href="<%=cpath%>/coupon/home/list?curPage=${listDTO.nextPage }">[다음]</a>
		</c:if>  
		<c:if test="${discount == 'discount'}">
			<a href="<%=cpath%>/coupon/home/discount?curPage=${listDTO.nextPage }">[다음]</a>
		</c:if>
		<c:if test="${today == 'today'}">
			<a href="<%=cpath%>/coupon/home/today?curPage=${listDTO.nextPage }">[다음]</a>
		</c:if>
		<c:if test="${readcnt == 'readcnt'}">
			<a href="<%=cpath%>/coupon/home/readcnt?curPage=${listDTO.nextPage }">[다음]</a>
		</c:if>
	</c:if>  
	</td>
  </tr>
<!-- /food/coupon/home/discount?curPage=2 --> 

 </table>
 <p>&nbsp;</p>
 <p>&nbsp;</p>
<p>&nbsp;</p>
 <p>&nbsp; </p>
<p>&nbsp;</p>



</body>
</html>

